/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: Dec 31, 2009
 * Time: 11:14:27 AM
 * To change this template use File | Settings | File Templates.
 */
import java.util.Iterator;
import java.util.List;
import org.jdom.Element;

// Referenced classes of package dk.brics.dsd:
//            Boolexp, Context, Validator, Schema

class ChildBoolexp extends Boolexp
{

    ChildBoolexp(Element element, Schema schema)
    {
        exp = parseOne(element, schema);
    }

    byte evaluate(Context context)
    {
        byte byte0 = 2;
        Iterator iterator = context.v.getChildren(context).iterator();
        do
        {
            if(!iterator.hasNext())
                break;
            byte byte1 = exp.evaluate((Context)iterator.next());
            if(byte1 == 1)
                return 1;
            if(byte1 == 4)
                byte0 = 4;
            else
            if(byte1 == 3 && byte0 == 2)
                byte0 = 3;
        } while(true);
        return byte0;
    }

    boolean isMentioned(Context context)
    {
        return false;
    }

    Element toXML(Context context)
    {
        return (new Element("child", "http://www.brics.dk/DSD/2.0")).addContent(exp.toXML(context));
    }

    boolean containsThis(Context context)
    {
        return exp.containsThis(context);
    }

    Boolexp exp;
}

